package org.ala.tiktools.generator.mybatis.creator.entity.pagerCountDO;

import freemarker.template.TemplateException;
import org.ala.tiktools.generator.mybatis.config.info.Part;
import org.ala.tiktools.generator.mybatis.creator.AbstractCreator;
import org.ala.tiktools.generator.mybatis.creator.entity.EntityInfo;
import org.ala.tiktools.generator.mybatis.dbinfo.TableInfo;
import org.ala.tiktools.generator.mybatis.tools.Tools;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ala
 * @date 2025-03-13 14:54
 */
public class PagerCountCreator extends AbstractCreator {

    /**
     *  生成Entity类
     */
    public PagerCountInfo create(Part part, TableInfo table, EntityInfo e) throws IOException, TemplateException {
        Map<String, Object> dataMeta = new HashMap<>();
        PagerCountInfo d = PagerCountInfo.build(part, table, e);
        dataMeta.put("d", d);

        String out = d.getPkg();
        out = this.getOutRootPath() + out.replaceAll("\\.", "/");
        Tools.existsAndMakeDirs(out);
        out = out + "/" + d.getClassName() + ".java";

        output("ShardPagerCountDO.ftl", dataMeta, out);

        System.out.println("生成PagerCountDO类. path:" + out);
        return d;
    }
}
